﻿using System;
using System.Collections.Generic;

using System.Web;
using com.byt.webcore;
using com.byt.suce.db.dao;
using com.byt.suce.db.factory;
using com.byt.suce.db.mapper;
using MYLSOFT.JsonSimple;
using com.byt.webcore.utils;

namespace suce.mant
{
    /// <summary>
    /// Summary description for Solicitud
    /// </summary>
    public class Mant : ServletBase
    {

        private IPkgMant DAO = PkgMantFactory.create();

        protected override void doCommand(com.byt.webcore.ServletBase.Parameters p)
        {
            if ("CLASIFICACION".Equals(p.command))
                CLASIFICACION(p);
            else if ("UIT".Equals(p.command))
                UIT(p);
            else if ("NOTIFICACIONES".Equals(p.command))
                NOTIFICACIONES(p);
            else if ("FORMATO".Equals(p.command))
                FORMATO(p);

        }

        private void CLASIFICACION(Parameters p)
        {
            if ("SEARCH".Equals(p.subcommand))
            {
                PkgMant.ClasificacionSearchParam param = DAO.clasificacionSearch(p.conn, p.getMap());
                p.print(Utils.getJSONArrayArray(param.CurOut));
                param.CurOut.Close();
            }
        }

        private void UIT(Parameters p)
        {
            if ("GETLIST".Equals(p.subcommand))
            {
                PkgMant.UitGetlistParam param = DAO.uitGetlist(p.conn, p.getMap());
                p.print(Utils.getJSONArrayArray(param.CurOut));
                param.CurOut.Close();
            }
            else if("GETBYID".Equals(p.subcommand))
            {
                PkgMant.UitGetbyidParam param = DAO.uitGetbyid(p.conn, p.getMap());
                p.print(Utils.getJSONObject(param.CurOut));
                param.CurOut.Close();
            }
            else if ("UPDATE".Equals(p.subcommand))
            {
                DAO.uitUpdate(p.conn, p.getMap());
            }
        }

        private void NOTIFICACIONES(Parameters p)
        {
            if ("GETLIST".Equals(p.subcommand))
            {
                PkgMant.ActGetlistParam param = DAO.actGetlist(p.conn, p.getMap());
                p.print(Utils.getJSONArrayArray(param.CurOut));
                param.CurOut.Close();
            }
        }

        private void FORMATO(Parameters p)
        {
            if ("GETLIST".Equals(p.subcommand))
            {
                PkgMant.FormatoGetlistParam param = DAO.formatoGetlist(p.conn, p.getMap());
                p.print(Utils.getJSONArrayArray(param.CurOut));
                param.CurOut.Close();
            }
        }
    }
}